﻿@model Tasks.UI.Models.Carcompany.CarManageModel
@{
    Layout = "~/Views/Account/_AccountMaster.cshtml";
}
@section head{
    <style type="text/css">
        /* 搜索栏 div */
        .search
        {
            background: url(/images/inquiry_bgtop.jpg) no-repeat;
            margin-top: 10px;
            margin-bottom: 10px;
            padding: 10px 0px 0px 0px;
        }
        .search table
        {
            padding: 2px;
            width: 100%;
            background: #cbecff url(/images/inquiry_bgbottom.jpg) no-repeat 0 bottom;
        }
    </style>
    <script type="text/javascript">

        $(function () {
            initProvince("#ProvinceID");
            initCity("#CityID");
            initTable(".tblStyle1");
        })

        function setState(carCompanyID, state) {
            $("#CarCompanyID").val(carCompanyID);
            goto(state);
        }

        function goto(act) {
            $("#act").val(act);
            document.forms[0].submit();
        }
        //删除数据
        function ConfirmDel(carCompanyID) {
            $.Msg.confirmDelete(
             function () {
                 $("#CarCompanyID").val(carCompanyID);
                 goto("delete");
             }
        );
        }
    </script>
}
@using (Html.BeginForm())
{
    <input id="act" name="act" type="hidden" />
    <input id="CarCompanyID" name="CarCompanyID" type="hidden" />
       
    <div class="navTitle">
        车队管理</div>
    <div class="searchBar">
        <table>
            <tr align="left">
                <td>
                    <strong>车队名称</strong>
                    @Html.TextBoxFor(t => t.Name)
                    <select name="Relation" id="Relation">
                        <option selected="selected" value="0">协议</option>
                        <option value="1">一般单位</option>
                        <option value="2">协议单位</option>
                    </select>
                    <strong>位置</strong>
                    @Html.DropDownList("ProvinceID", PageHelper.ProvinceSelector(Model.ProvinceID))
                    @Html.DropDownList("CityID", PageHelper.CitySelector(Model.CityID, Model.ProvinceID))
                    @Html.DropDownList("AreaID", PageHelper.AreaSelector(Model.AreaID, Model.CityID))
                    <input id="btnSearch" type="button" value="查询" onclick="goto('search')" class="btnSearch" />
                    <a href="javascript:void(0)" onclick="openTab('添加车队','/Account/CarEdit',true)">添加</a>
                </td>
            </tr>
        </table>
        <div class="bottom">
        </div>
    </div>
    <div class="pageBody">
        <table border="0" cellspacing="0" cellpadding="0" class="tblStyle1">
            <thead>
                <tr align="center">
                    <th style="width: 60px">
                        状态
                    </th>
                    <th style="width: 120px">
                        省份
                    </th>
                    <th>
                        车队
                    </th>
                    <th>
                        付款方式
                    </th>
                    <th style="width: 100px">
                        联系人
                    </th>
                    <th style="width: 100px">
                        手机号码
                    </th>
                    <th style="width: 160px">
                        备注
                    </th>
                    <th style="width: 120px">
                        操作
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (CarCompany car in Model.CarCompany)
                {
                    if (car.Contact == null)
                    {
                        car.Contact = new ContactInfo();
                    }
                    <tr align="center">
                        <td>
                            @if (car.State == (int)Tasks.Common.Enum.CarcompanyState.无效)
                            {
                                <span>停止</span>
                                      
                            }
                            else
                            {
                                <span>正常</span>
                            }
                        </td>
                        <td>
                           @car.Contact.Position
                        </td>
                        <td>
                            <a href="ViewCar?CarCompanyID=@car.CarCompanyID" title="查看车队详细信息">@car.Name</a>
                        </td>
                        <td>
                            @CommonUtil.GetEnumDescription(typeof(EnterprisePaymentMode), car.PaymentMode)
                        </td>
                        <td>@car.Contact.Linkman
                        </td>
                        <td>@car.Contact.LinkmanMobileNo
                        </td>
                        <td>@Html.Truncate(car.Remark, 30)
                        </td>
                        <td width="200" valign="bottom">
                            <a href="javascript:void(0)" onclick="openTab('编辑车队','/Account/CarEdit?CarCompanyID=@car.CarCompanyID',true)">
                                <img src="/images/icon/16x16/file_edit.png" title="编辑" /></a> <a href="javascript:;" onclick="ConfirmDel(@car.CarCompanyID)" title="删除">
                                    <img src="/images/icon/16x16/delete.png" title="删除" /></a>
                            @if (car.State == (int)Tasks.Common.Enum.CarcompanyState.无效)
                            {
                                <a href="javascript:;" onclick="setState(@car.CarCompanyID,'tostart')" title="状态：停用或启用">
                                    <img src="/images/icon/16x16/enable.png" title="启用" /></a>
                            }
                            @if (car.State == (int)Tasks.Common.Enum.CarcompanyState.有效)
                            {
                                <a href="javascript:;" onclick="setState(@car.CarCompanyID,'blockup')" title="状态：停用或启用">
                                    <img src="/images/icon/16x16/stop.png" title="禁用" /></a>
                            }
                        </td>
                    </tr>
                }
            </tbody>
        </table>
        @Html.RenderPageNav(Model.PageIndex, Model.PageSize, Model.RowCount, "", PageNavStyle.Form)
    </div>
 
}
